//package com.cn.service;
//
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//import org.springframework.amqp.rabbit.support.CorrelationData;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//
//import java.util.UUID;
//
///**
// * @Author jiangwang
// * @Created by 2020/10/14 11:33
// * @Description: TODO
// */
//@Service
//public class RabbitMessageSendService
//{
//
//    private static final Logger logger = LoggerFactory.getLogger(RabbitMessageSendService.class);
//
//    //自动注入RabbitTemplate模板类
//    @Autowired
//    private RabbitTemplate rabbitTemplate;
//
//    //回调函数: confirm确认
//    private final RabbitTemplate.ConfirmCallback confirmCallback = (correlationData, ack, cause) ->
//    {
//        if (ack)
//        {
//            //成功发送返回
//            logger.info("callback confirm :" + correlationData.getId());
//        }
//        else
//        {
//            //失败处理
//            logger.error("失败消息ID-----" + (correlationData == null ? "" : correlationData.getId()));
//        }
//    };
//
//    //发送消息方法调用: 构建自定义对象消息
//    public void sendMessage(Object message)
//    {
//        try
//        {
//            rabbitTemplate.setConfirmCallback(confirmCallback);
//            //消息唯一ID
//            CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString().replace("-", "").toUpperCase());
//            logger.info("callbackSender UUID :" + correlationData.getId());
//            rabbitTemplate.convertAndSend("CY_TMS", "cy_test", message, correlationData);
//        }
//        catch (Exception e)
//        {
//            logger.error(message.toString(), e);
//        }
//    }
//}
